package com.liuwei.assemble.factory;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.liuwei.assemble.dtos.GeneratorContextDTO;
import com.liuwei.assemble.services.IGeneratorProject;
import com.liuwei.assemble.services.impl.SpringBootGenerator;
import com.liuwei.assemble.services.impl.BootStrapGenerator;


/**
 * @author liuwei19
 */
public class GeneratorFactory {
    private static final Logger logger = LoggerFactory.getLogger(GeneratorFactory.class);

    public static IGeneratorProject getGeneratorProject(String projectType){
        IGeneratorProject generatorProject = null;
        if(StringUtils.isNotBlank(projectType)){
            switch (projectType){
                case "springboot":generatorProject = new SpringBootGenerator(); break;
                case "bootstrap":generatorProject = new BootStrapGenerator(); break;
            }
        }
        return generatorProject;
    }

    public static void generator(String projectType,GeneratorContextDTO generatorParam) throws Exception{
        IGeneratorProject generatorProject = GeneratorFactory.getGeneratorProject(projectType);
        logger.error("projectType:{}",projectType);
        logger.error("generatorProject:{}",generatorProject);
        if (generatorProject != null) {
            logger.error("stt1:{}",generatorProject);
            generatorProject.generator(generatorParam);
        }
    }
}
